/*
 * © Copyright 2011 Romain Marteau, Matthieu Totet
 * 
 *    This file is part of VineaToum.
 *
 *    VineaToum is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *
 *    VineaToum is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with VineaToum.  If not, see <http://www.gnu.org/licenses/>.
 *    
 */

package org.vineatoum.business.action.analyse;

import java.util.Date;
import java.util.Vector;

import org.vineatoum.business.action.abstraction.Analyse;
import org.vineatoum.view.utils.jtablecustom.TableListener;


public class AnalyseLabo extends Analyse {
	private static String DATE = "Date";
	private static String TITRE_ACLOO = "Titre Alcoométrique (% vol)";
	private static String GLUC_FRUC = "Glucose, Fructose (g/l)";
	private static String ACIDITE_VOLATILE = "Acidité volatile (g/l)";
	private static String ACIDITE_ACETIQUE = "Acidité acétique (g/l)";
	private static String ACIDITE_VOLATILE_CALCULEE = "Acidité volatile calculée (mEq/l)";
	private static String ACIDITE_TOTALE_G = "Acidité totale (g/l)";
	private static String ACIDITE_TOTALE_MEQ = "Acidité totale (mEq/l)";
	private static String PH = "pH";
	private static String SO2_LIBRE = "SO2 libre (mg/l)";
	private static String SO2_TOTAL = "SO2 total (mg/l)";
	private static String ACIDE_MALIQUE = "Acide Malique (g/l)";
	private static String FER = "Fer (mg/l)";
	private static String COMMENT = "Commentaire";
	
	private Float titre_alcoo = new Float(0);
	private Float gluc_fruc = new Float(0);
	private Float acidite_volatile = new Float(0);
	private Float acidite_acetique = new Float(0);
	private Float acidite_volatile_calculee = new Float(0);
	private Float acidite_totale_g = new Float(0);
	private Float acidite_totale_meq = new Float(0);
	private Float ph = new Float(0);
	private Float so2libre = new Float(0);
	private Float so2total = new Float(0);
	private Float acide_malique = new Float(0);
	private Float fer = new Float(0);
	private String comment;
	
	
	@Override
	public TableListener getNewInstance() {
		return new AnalyseLabo();
	}

	@Override
	public Vector<String> getVectorColumns() {
		Vector<String> columns = new Vector<String>();
		columns.add(DATE);
		columns.add(TITRE_ACLOO);
		columns.add(GLUC_FRUC);
		columns.add(ACIDITE_VOLATILE);
		columns.add(ACIDITE_ACETIQUE);
		columns.add(ACIDITE_VOLATILE_CALCULEE);
		columns.add(ACIDITE_TOTALE_G);
		columns.add(ACIDITE_TOTALE_MEQ);
		columns.add(PH);
		columns.add(SO2_LIBRE);
		columns.add(SO2_TOTAL);
		columns.add(ACIDE_MALIQUE);
		columns.add(FER);
		columns.add(COMMENT);
		return columns;
	}

	@Override
	public Vector<Object> getVectorData() {
		Vector<Object> values = new Vector<Object>();
		values.add(date);
		values.add(titre_alcoo);
		values.add(gluc_fruc);
		values.add(acidite_volatile);
		values.add(acidite_acetique);
		values.add(acidite_volatile_calculee);
		values.add(acidite_totale_g);
		values.add(acidite_totale_meq);
		values.add(ph);
		values.add(so2libre);
		values.add(so2total);
		values.add(acide_malique);
		values.add(fer);
		values.add(comment);
		return values;
	}

	@Override
	public void updateField(String field, Object value) {
		try {
			if(field == DATE) {
				date = (Date)value;
			} else if (field == TITRE_ACLOO) {
				titre_alcoo = (Float)value;
			} else if (field == GLUC_FRUC) {
				gluc_fruc = (Float)value;
			} else if (field == ACIDITE_VOLATILE) {
				acidite_volatile = (Float)value;
			} else if (field == ACIDITE_ACETIQUE) {
				acidite_acetique = (Float)value;
			} else if (field == ACIDITE_VOLATILE_CALCULEE) {
				acidite_volatile_calculee = (Float)value;
			} else if (field == ACIDITE_TOTALE_G) {
				acidite_totale_g = (Float)value;
			} else if (field == ACIDITE_TOTALE_MEQ) {
				acidite_totale_meq = (Float)value;
			} else if (field == PH) {
				ph = (Float)value;
			} else if (field == SO2_LIBRE) {
				so2libre = (Float)value;
			} else if (field == SO2_TOTAL) {
				so2total = (Float)value;
			} else if (field == ACIDE_MALIQUE) {
				acide_malique = (Float)value;
			} else if (field == FER) {
				fer = (Float)value;
			} else if (field == COMMENT) {
				comment = (String)value;
			} 
			
		} catch (Exception e) {
			System.err.println("error parsing in AnalyseLabo for field " + field);
			// TODO: handle exception
		}
	}
	
	public Float getTitre_alcoo() {
		return titre_alcoo;
	}

	public void setTitre_alcoo(Float titre_alcoo) {
		this.titre_alcoo = titre_alcoo;
	}

	public Float getGluc_fruc() {
		return gluc_fruc;
	}

	public void setGluc_fruc(Float gluc_fruc) {
		this.gluc_fruc = gluc_fruc;
	}

	public Float getAcidite_volatile() {
		return acidite_volatile;
	}

	public void setAcidite_volatile(Float acidite_volatile) {
		this.acidite_volatile = acidite_volatile;
	}

	public Float getAcidite_acetique() {
		return acidite_acetique;
	}

	public void setAcidite_acetique(Float acidite_acetique) {
		this.acidite_acetique = acidite_acetique;
	}

	public Float getAcidite_volatile_calculee() {
		return acidite_volatile_calculee;
	}

	public void setAcidite_volatile_calculee(Float acidite_volatile_calculee) {
		this.acidite_volatile_calculee = acidite_volatile_calculee;
	}

	public Float getAcidite_totale_g() {
		return acidite_totale_g;
	}

	public void setAcidite_totale_g(Float acidite_totale_g) {
		this.acidite_totale_g = acidite_totale_g;
	}

	public Float getAcidite_totale_meq() {
		return acidite_totale_meq;
	}

	public void setAcidite_totale_meq(Float acidite_totale_meq) {
		this.acidite_totale_meq = acidite_totale_meq;
	}

	public Float getPh() {
		return ph;
	}

	public void setPh(Float ph) {
		this.ph = ph;
	}

	public Float getSo2libre() {
		return so2libre;
	}

	public void setSo2libre(Float so2libre) {
		this.so2libre = so2libre;
	}

	public Float getSo2total() {
		return so2total;
	}

	public void setSo2total(Float so2total) {
		this.so2total = so2total;
	}

	public Float getAcide_malique() {
		return acide_malique;
	}

	public void setAcide_malique(Float acide_malique) {
		this.acide_malique = acide_malique;
	}

	public Float getFer() {
		return fer;
	}

	public void setFer(Float fer) {
		this.fer = fer;
	}

	public String getComment() {
		return comment;
	}

	public void setComment(String comment) {
		this.comment = comment;
	}
}
